<template>
  <div id="app">
    <bar-top></bar-top>
    <router-view></router-view>
    <error-dialog></error-dialog>
    <loading v-show="this.$store.state.showLoading"></loading>
  </div>
</template>

<script>
import barTop from './components/barTop.vue';
import loading from './components/loading.vue';
import errorDialog from './components/errorDialog'

// 获取config配置数据
function getConfig() {
    var locationObject;
    $.ajax({
        type: 'post',
        dataType: "json",
        url: get_config_url,
        data:  {
            "mapUrl": "/tltd/Lenovo/"
        },
        cache: false,
//        async: false,
        contentType: "application/x-www-form-urlencoded; charset=UTF-8",
        success: function(msg) {
            console.dir(msg);
//            alert(JSON.stringify(msg))
            locationObject = msg;
            setConfig(msg);
        },
        error: function(msg) {
            console.dir(msg);
            alert("摄像头授权失败");

        }
    });

    return locationObject;
}

function setConfig(msg) {
    wx.config({
        debug: false,
        appId: msg.appid?msg.appid:appId, //'wxf8b4f85f3a794e77',
        timestamp: msg.timestamp,
        nonceStr: msg.nonceStr,
        signature: msg.signature,
        jsApiList: ['scanQRCode']
    });

}

export default {
    name: 'app',
    components: {
        'bar-top': barTop,
        'loading': loading,
        'error-dialog':errorDialog,
    },
    data(){
        return {
            userName:"测试用户"
        }
    },
    methods:{
        clearErroMsg(){
            this.$store.state.errorMsg = "";
        }
    },
    mounted:function () {
        console.log("tttt......")
//        alert("app mounted ....")
        getConfig();
    }
};
</script>

<style  lang='scss'>
@import './assets/scss/flashloanTltd/index.scss';
@import './assets/scss/components/_header.scss';
@import './assets/scss/components/xtCommon.scss';

body{
   background:#f5f5f9;
}
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

}

.btn_box{
    margin-top: 15px;
    padding:15px;
}

a:visited{
    color: #222;
}

</style>
